clear
version 7.0
#delimit ;
cd "Z:\interactionmodels\";                       * SET WORKING DIRECTORY;
log using getdata\getdata1_mozaffar.log, replace; 

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      getdata1_mozaffar.do                            *;
*       Date:           01/08/07                                        *;
*       Author:         MRG                                             *;
*       Purpose:        Recode Mozaffar et al. (2003) and relabel.      *;
*       Input File:     mozaffar.dta, golder1.dta                       *;
*       Output File:    getdata1_mozaffar.log                           *;
*       Data Output:    STATA_mozaffar.dta                              *;
*       Previous file:                                                  *;
*       Machine:                                                        *;
*     ****************************************************************  *;
*     ****************************************************************  *;

set mem 10m;                            

use getdata\mozaffar.dta;                     

*     ****************************************************************  *;
*           Summary Statistics                                          *;
*     ****************************************************************  *;

sum;

*     ****************************************************************  *;
*               Recode and relabel variables to sensible names          *;
*     ****************************************************************  *;

rename countrys country;
label var country "country";

rename enlp legparties;
label var legparties "effective number of parliamentary parties";

rename enep elecparties;
label var elecparties "effective number of electoral parties";

rename dismagni avemagnitude;
label var avemagnitude "average district magnitude";

rename logmagni logmag10;
label var logmag10 "log of average district magnitude (base 10) - NOT natural log";

rename proxmity proximity;
label var proximity "temporal proximity of legislative and presidential elections";

rename enpres prescandidate;
label var prescandidate "effective number of presidential candidates";

rename proxenpr prox_prescandidate;
label var prox_prescandidate "proximity * prescandidate";

rename ltfragto fragmentation;
label var fragmentation "fragmentation index (mozaffar 2003)";

rename fragtosq fragmentation2;
label var fragmentation2 "fragmentation squared";

rename contot concentration;
label var concentration "concentration of ethnic groups";

rename intertot frag_conc;
label var frag_conc "fragmentation * concentration";

rename intertsq frag2_conc;
label var frag2_conc "fragmentation2 * concentration";

rename lmgtrpls logmag10_frag2_conc;
label var logmag10_frag2 "logmag10 * fragmentation2 * concentration";

label var elf "ethno-linguistic group index";

rename elflmag logmag10_elf;
label var logmag10_elf "logmag10* elf";

rename pregblmg pregb_logmag10;
label var pregb_logmag10 "pregb * logmag10";

label var pregb "politically relevant ethnic group B count";

*     ****************************************************************  *;
*           Create new variables that we might want.                    *;
*     ****************************************************************  *;

gen logmag = ln(avemagnitude);
label var logmag "natural log of average district magnitude";

*     ****************************************************************  *;
*       Create necessary interaction terms involving logmag10           *;
*     ****************************************************************  *;

gen logmag10_conc = logmag10*concentration;
label var logmag10_conc "logmag10*concentration";

gen logmag10_frag = logmag10*fragmentation;
label var logmag10_frag "logmag10*fragmentation";

gen logmag10_frag_conc = logmag10*fragmentation*concentration;
label var logmag10_frag_conc "logmag10 * fragmentation * concentration";

*     ****************************************************************  *;
*       Now create necessary interaction terms involving logmag         *;
*     ****************************************************************  *;

gen logmag_conc = logmag*concentration;
label var logmag_conc "logmag*concentration";

gen logmag_frag = logmag*fragmentation;
label var logmag_frag "logmag*fragmentation";

gen logmag_frag_conc = logmag*fragmentation*concentration;
label var logmag_frag_conc "logmag * fragmentation * concentration";

sum;
describe;

*     ****************************************************************  *;
*       Now merge this dataset with golder1.dta so that we obtain       *;
*       variables indicating the year of the election and whether the   *;
*       country was a dictatorship (Note: no other info is added here). *;
*     ****************************************************************  *;

merge using getdata\golder1.dta, keep(year_nyu dictator_nyu) nokeep;
drop _merge;

*     ****************************************************************  *;
*                           Reorder the data                            *;
*     ****************************************************************  *;

order country year_nyu dictator_nyu;

*     ****************************************************************  *;
*                                   Save                                *;
*     ****************************************************************  *;

save    getdata\STATA_mozaffar, replace; 
log close;
exit;
